package com.mycat.task.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mycat.task.dao.mapper.ScheduleTaskExecuteDetailMapper;
import com.mycat.task.entity.ScheduleTaskExecuteDetail;
import com.mycat.task.service.ScheduleTaskExecuteDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ScheduleTaskExecuteDetailServiceImpl implements ScheduleTaskExecuteDetailService {

    @Autowired
    private ScheduleTaskExecuteDetailMapper scheduleTaskExecuteDetailMapper;

    @Override
    public void save(ScheduleTaskExecuteDetail scheduleTaskExecuteDetail) {
        scheduleTaskExecuteDetailMapper.insertUseGeneratedKeys(scheduleTaskExecuteDetail);
    }

    @Override
    public void edit(ScheduleTaskExecuteDetail scheduleTaskExecuteDetail) {
        scheduleTaskExecuteDetailMapper.updateByPrimaryKeySelective(scheduleTaskExecuteDetail);
    }

    @Override
    public void delete(Integer[] ids) {
        for (Integer id : ids) {
            scheduleTaskExecuteDetailMapper.deleteByPrimaryKey(id);
        }
    }

    @Override
    public ScheduleTaskExecuteDetail findScheduleTaskExecuteDetail(Integer id) {
        return  scheduleTaskExecuteDetailMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<ScheduleTaskExecuteDetail> page(Page<ScheduleTaskExecuteDetail> page) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<ScheduleTaskExecuteDetail>  datas =  scheduleTaskExecuteDetailMapper.selectAll();
        PageInfo<ScheduleTaskExecuteDetail> pageInfo = new PageInfo<>(datas);
        return pageInfo;
    }

}